package com.qfmy.web.app.mapper.novel;

import com.qfmy.model.entity.novel.Chapter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.mapper.novel
 * @date 2025/10/31
 * @description 小说章节
 */
@Mapper
public interface ChapterMapper {

    /**
     * 根据小说ID获取章节
     *
     * @param novelId
     * @return
     */
    List<Chapter> getChaptersByNovelId(Integer novelId);

    /**
     * 根据章节ID获取最新章节名称
     * @param lastChapterId
     * @param novelId
     * @return
     */
    @Select("select title from chapter where chapter_index = #{lastChapterId} and novel_id = #{novelId}")
    String getChapterByIndex(Integer lastChapterId, Integer novelId);

    /**
     * 根据小说ID获取章节详情
     * @param novelId
     * @return
     */
    List<Chapter> getChapterDetailsByNovelId(Integer novelId);

    /**
     * 根据章节ID和小说ID获取章节详情
     *
     * @param novelId
     * @param chapterIndex
     * @return
     */
    Chapter getChapterDetails(Integer novelId,Integer chapterIndex);


}
